package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzbqCpuinfo;
import com.ruoyi.system.service.IDzbqCpuinfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * CPU型号Controller
 * 
 * @author tianxingxia
 * @date 2025-01-31
 */
@RestController
@RequestMapping("/system/cpuinfo")
public class DzbqCpuinfoController extends BaseController
{
    @Autowired
    private IDzbqCpuinfoService dzbqCpuinfoService;

    /**
     * 查询CPU型号列表
     */
    @PreAuthorize("@ss.hasPermi('system:cpuinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(DzbqCpuinfo dzbqCpuinfo)
    {
        startPage();
        List<DzbqCpuinfo> list = dzbqCpuinfoService.selectDzbqCpuinfoList(dzbqCpuinfo);
        return getDataTable(list);
    }

    /**
     * 导出CPU型号列表
     */
    @PreAuthorize("@ss.hasPermi('system:cpuinfo:export')")
    @Log(title = "CPU型号", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzbqCpuinfo dzbqCpuinfo)
    {
        List<DzbqCpuinfo> list = dzbqCpuinfoService.selectDzbqCpuinfoList(dzbqCpuinfo);
        ExcelUtil<DzbqCpuinfo> util = new ExcelUtil<DzbqCpuinfo>(DzbqCpuinfo.class);
        util.exportExcel(response, list, "CPU型号数据");
    }

    /**
     * 获取CPU型号详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:cpuinfo:query')")
    @GetMapping(value = "/{cpuId}")
    public AjaxResult getInfo(@PathVariable("cpuId") Integer cpuId)
    {
        return success(dzbqCpuinfoService.selectDzbqCpuinfoByCpuId(cpuId));
    }

    /**
     * 新增CPU型号
     */
    @PreAuthorize("@ss.hasPermi('system:cpuinfo:add')")
    @Log(title = "CPU型号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzbqCpuinfo dzbqCpuinfo)
    {
        return toAjax(dzbqCpuinfoService.insertDzbqCpuinfo(dzbqCpuinfo));
    }

    /**
     * 修改CPU型号
     */
    @PreAuthorize("@ss.hasPermi('system:cpuinfo:edit')")
    @Log(title = "CPU型号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzbqCpuinfo dzbqCpuinfo)
    {
        return toAjax(dzbqCpuinfoService.updateDzbqCpuinfo(dzbqCpuinfo));
    }

    /**
     * 删除CPU型号
     */
    @PreAuthorize("@ss.hasPermi('system:cpuinfo:remove')")
    @Log(title = "CPU型号", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cpuIds}")
    public AjaxResult remove(@PathVariable Integer[] cpuIds)
    {
        return toAjax(dzbqCpuinfoService.deleteDzbqCpuinfoByCpuIds(cpuIds));
    }
}
